package com.mz.ozy.adapter;

import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;

import java.util.List;

/**
 * Created by Administrator on 2019/3/25.
 */

public class TrainPlanAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private TextView mTvSelected;
    private int mSelectIndex = 0;

    public TrainPlanAdapter(List<String> data) {
        super(R.layout.item_fitness_train_plan, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        helper.setText(R.id.tv_purpose, item);
        final TextView contentView = helper.getView(R.id.tv_purpose);
        if (mSelectIndex == helper.getAdapterPosition()) {
            mTvSelected = contentView;
            contentView.setTextColor(ContextCompat.getColor(mContext, R.color.c_4298fd));
            contentView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        } else {
            contentView.setTextColor(ContextCompat.getColor(mContext, R.color.c_707477));
            contentView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
        }
    }

    public void clickSelectView(View contentView, int position) {
        if (mTvSelected != null) {
            mTvSelected.setTextColor(ContextCompat.getColor(mContext, R.color.c_707477));
            mTvSelected.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
        }
        mSelectIndex = position;
        TextView textView = contentView.findViewById(R.id.tv_purpose);
        textView.setTextColor(ContextCompat.getColor(mContext, R.color.c_4298fd));
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        mTvSelected = textView;
    }
}
